package com.zjlanyun.erp.view;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zjlanyun.erp.R;
import com.zjlanyun.erp.nohttp.CallServer;
import com.zjlanyun.erp.utils.StatusBarUtil;

import butterknife.Bind;
import butterknife.ButterKnife;
import me.imid.swipebacklayout.lib.app.SwipeBackActivity;

/**
 * Created by lanyun on 16/5/13.
 * 基础侧滑返回Activity类
 */
public class BaseSwipeBackActivity extends SwipeBackActivity {

    @Bind(R.id.title) public TextView title;
    @Bind(R.id.ll_back) public LinearLayout ll_back;
    @Bind(R.id.ll_status_bar) LinearLayout ll_status_bar;

    private int statusBarLightMode = 0;
    public Context mContext = this;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //设置状态栏颜色
        statusBarLightMode = StatusBarUtil.StatusBarLightMode(this);
        if (statusBarLightMode > 0) {
            StatusBarUtil.transparencyBar(this);
        }
    }

    /**
     * 基础初始化
     */
    public void initBaseView() {
        ButterKnife.bind(this);

        //显示布局文件中的状态栏
        if (statusBarLightMode > 0) {
            ll_status_bar.setVisibility(View.VISIBLE);
        }

        //后退
        ll_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void onDestroy() {
        CallServer.getRequestInstance().cancelBySign(mContext);
        ButterKnife.unbind(this);
        super.onDestroy();
    }
}
